Skip to content

Refactor Transcoding#358

Open
Shadowghost wants to merge 5 commits intojellyfin:masterfrom
Shadowghost:refactor-play-utils
Open

Refactor Transcoding#358
Shadowghost wants to merge 5 commits intojellyfin:masterfrom
Shadowghost:refactor-play-utils

Conversation

@Shadowghost
Copy link
Contributor

@Shadowghost Shadowghost commented Dec 27, 2024

Changes:

  • Use fMP4 for HLS which supports more codecs when transcoding/remuxing
  • Use server-provided subtitle download URLs with correct codec file ending
  • Fix transcoding bitrate selector
  • Only enforce transcoding settings on forced transcode - otherwise remuxing will never happen

Issue:

@mcarlton00
Copy link
Member

Just testing functionality right now

when trying to force transcode a movie. Set the bitrate, select the subtitle stream. It seems to work on another option that also has an audio stream selection.

2025-01-18 11:19:32.294 T:1178360   error <general>: Exception in thread
2025-01-18 11:19:32.294 T:1178360   error <general>: Thread-4
2025-01-18 11:19:32.294 T:1178360   error <general>: :

2025-01-18 11:19:32.295 T:1178360   error <general>: Traceback (most recent call last):

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/usr/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
                                                       self.run()
                                                       ~~~~~~~~^^

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/monitors.py", line 41, in run
                                                       show_menu(params)
                                                       ~~~~~~~~~^^^^^^^^

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/functions.py", line 556, in show_menu
                                                       play_action(params)
                                                       ~~~~~~~~~~~^^^^^^^^

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/functions.py", line 943, in play_action
                                                       play_file(play_info)
                                                       ~~~~~~~~~^^^^^^^^^^^

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/tracking.py", line 25, in wrapper
                                                       value = func(*args, **kwargs)

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/play_utils.py", line 464, in play_file
                                                       playurl = audio_subs_pref(playurl, list_item, selected_media_source, item_id, audio_stream_index,
                                                                                 subtitle_stream_index)

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>:   File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/play_utils.py", line 868, in audio_subs_pref
                                                       delivery_url = downloadable_streams[select_subs_index]['DeliveryUrl']
                                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

2025-01-18 11:19:32.296 T:1178360   error <general>:
2025-01-18 11:19:32.296 T:1178360   error <general>: TypeError: 'int' object is not subscriptable

When trying to playback a livetv stream:

2025-01-18 11:21:36.798 T:1181919    info <general>: JELLYFIN.resources.lib.functions -> INFO::resources/lib/functions.py:942 Sending jellycon_play_action : {'action': 'play', 'item_id': 'a0242c16b96145b49c9bb758fb5495a3', 'auto_resume': '-1', 'force_transcode': False, 'media_source_id': '', 'subtitle_stream_index': None, 'audio_stream_index': None}
2025-01-18 11:21:43.452 T:1181919   error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'KeyError'>
                                                   Error Contents: 'TranscodingUrl'
                                                   Traceback (most recent call last):
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/default.py", line 18, in <module>
                                                       main_entry_point()
                                                       ~~~~~~~~~~~~~~~~^^
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/tracking.py", line 25, in wrapper
                                                       value = func(*args, **kwargs)
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/functions.py", line 156, in main_entry_point
                                                       play_action(params)
                                                       ~~~~~~~~~~~^^^^^^^^
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/functions.py", line 943, in play_action
                                                       play_file(play_info)
                                                       ~~~~~~~~~^^^^^^^^^^^
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/tracking.py", line 25, in wrapper
                                                       value = func(*args, **kwargs)
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/play_utils.py", line 424, in play_file
                                                       playurl, playback_type, listitem_props = get_play_url(selected_media_source, play_session_id, channel_id)
                                                                                                ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                     File "/home/matt/.kodi/addons/plugin.video.jellycon/resources/lib/play_utils.py", line 1244, in get_play_url
                                                       playurl = '{}{}'.format(server, media_source['TranscodingUrl'])
                                                                                       ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
                                                   KeyError: 'TranscodingUrl'
                                                   -->End of Python script error report<--

@Shadowghost
Copy link
Contributor Author

Just to understand, this only appears if you force transcode a media file with exactly one video, one audio but multiple subtitle streams?

@Shadowghost
Copy link
Contributor Author

@mcarlton00 I'd need some more guidance on how to reproduce the first failure since I am unable to. I also don't have a LiveTV setup to debug the second issue any further

@mcarlton00
Copy link
Member

For the first error:

One video stream, one audio stream, multiple subtitle streams. Media info of the file in question that's failing
2025-02-22_09-06-16

I think the livetv handling needs to be reworked anyway. I'll put it on my list to look into

Copy link
Member

@mcarlton00 mcarlton00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also just noticed that switching to mp4 has caused me to only get 10 seconds of playback and then the stream stalls out and eventually dies. Almost like it's only getting the first segment. Switching back to ts for the Container type and things play as expected again. I can't find anything stating this is a limitation of Kodi, but something isn't working right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for fMP4

2 participants